package de.koller.million.enc.engine;

import de.koller.million.enc.EncNode;
import de.koller.million.enc.network.Connection;
import de.koller.million.enc.network.netpack.TimeSync;

public class UserCommunication extends EncNode {

	private long nextTimeSync = 0;
	
	@Override
	protected void update( Object... refernces ) {
		super.update( refernces );
		
		timeSync();
	}
	
	private void timeSync() {
		if( nextTimeSync > root.engine.getTime() )
			return;
		
		nextTimeSync = root.engine.getTime() + 2_000;
		for( Connection c : root.network.getConnections() ) 
			c.getToSend().push( new TimeSync( root.engine.getTime() ) );
	}
	
}
